<script lang="ts">
//打字机特效
import { defineComponent, toRefs,ref } from "vue";

export default defineComponent({
  name: "H5Typewriter",
  props: {
    text: {
      type: String,
      default: "",
    },
  },
  setup(props) {
    const { text } = toRefs(props);
    const showTest=ref<String>('')
    
    let index=0;

    const effectTyping=()=>{
      showTest.value=  text.value.substring(0,index++);
    }

    setInterval(effectTyping,200);

    return {showTest};
  },
});
</script>

<template>
  <div>{{showTest}}</div>
</template>

<style lang="scss" scoped></style>
